<template>
	<view>
		<view class="">
			<view class="center ">
				<view class="d-flex bb" @tap="goAccount">
					<view class="flex-1 mt-3 mb-3 ml-2 fs28 ls2">账户中心</view>
					<image class="m-2 mt-4" src="@/static/img/user/right.png" mode="widthFix" style="width: 15rpx;">
					</image>
				</view>
				<view class="d-flex bb" @tap="change">
					<view class="flex-1 mt-3 mb-3 ml-2 fs28 ls2">账号与安全</view>
					<image class="m-2 mt-4" src="@/static/img/user/right.png" mode="widthFix" style="width: 15rpx;">
					</image>
				</view>
				<view class="d-flex bb" @tap="goServiceContract">
					<view class="flex-1 mt-3 mb-3 ml-2 fs28 ls2">用户协议</view>
					<image class="m-2 mt-4" src="@/static/img/user/right.png" mode="widthFix" style="width: 15rpx;">
					</image>
				</view>
				<view class="d-flex bb" @tap="goPrivacyPolicy">
					<view class="flex-1 mt-3 mb-3 ml-2 fs28 ls2">隐私政策</view>
					<image class="m-2 mt-4" src="@/static/img/user/right.png" mode="widthFix" style="width: 15rpx;">
					</image>
				</view>
				<view class="d-flex bb" @tap="checkVersion">
					<view class="flex-1 mt-3 mb-3 ml-2 fs28 ls2">版本号</view>
					<view class="gray fs28 m-3">{{version}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		props: {
			version: {
				value: String,
				default: ''
			}
		},
		methods: {
			goAccount() {
				uni.navigateTo({
					url: '/pages/user/account'
				})
			},

			change() {
				uni.navigateTo({
					url: '/pages/user/change'
				})
			},

			goServiceContract() {
				uni.navigateTo({
					url: '/pages/docs/service-contract'
				})
			},

			goPrivacyPolicy() {
				uni.navigateTo({
					url: '/pages/docs/privacy-policy'
				})
			},

			async checkVersion() {
				let current_verson = this.$version;
				let res = await this.$myRequest({
					url: '/configs',
					data: {
						name: 'software_version'
					}
				})

				if (current_verson != res.data.data) {
					// #ifdef APP-PLUS
					switch (uni.getSystemInfoSync().platform) {
						case 'android':
							this.$api.msg('即将进入首页下载最新版！');
							setTimeout(() => {
								uni.reLaunch({
									url: '/pages/index/index'
								})
							}, 3000)
							break;
						case 'ios':
							this.$api.msg('苹果版本开发中，即将进入手机版！');
							setTimeout(() => {
								plus.runtime.openUrl('http://ldlwq.hnliandesy.com/h5/#/')
							}, 3000)

							break;
						default:
							console.log('运行在开发者工具上')
							break;
					}
					// #endif
				}
			}
		},
	}
</script>

<style>
	.center {
		width: 94%;
		height: 100%;
		background-color: white;
		margin: 20rpx auto;
		border-radius: 20rpx;
	}

	.bb {
		border: 1rpx solid #f3f3f3;
	}
</style>
